package questionSolution.Question_11;

import java.util.Scanner;

public class Solution_1 {
    public int maxArea(int[] height){
        int max = 0;
        int left = 0;
        int right = height.length - 1;
        while(left < right){
            int contains = Math.min(height[left], height[right]) * (right - left);
            max = Math.max(max, contains);
            if(height[left] < height[right]){
                left++;
            }
            else{
                right--;
            }
        }
        return max;
    }

    static void main() {
        Solution_1 s = new Solution_1();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] height = new int[n];
        for (int i = 0; i < n; i++) {
            height[i] = sc.nextInt();
        }
        int result = s.maxArea(height);
        System.out.println(result);
    }
}
